package com.design.memento.text;

// 备忘录类
class EditorMemento {
    private String content;

    public EditorMemento(String content) {
        this.content = content;
    }

    public String getContent() {
        return content;
    }
}

// 原始对象类
class TextEditor {
    private StringBuilder content = new StringBuilder();
    
    public void append(String text) {
        content.append(text);
    }
    
    public String getContent() {
        return content.toString();
    }
    
    public EditorMemento save() {
        return new EditorMemento(content.toString());
    }
    
    public void restore(EditorMemento memento) {
        content = new StringBuilder(memento.getContent());
    }
}
